
<?php	
	
	class categoryproduct extends database
	{
		var $connection = '';	

		function categoryproduct()
		{
			parent::database();
		}
	
		function GetListPaging()
		{						
			$this->setQuery("set names utf8");
			$this->query();
			return $sql = "Select * from vnf_category_product ";			
			//return $pager;
			//$rs = $pager->paginate();
	//Loop through the result set
				
			/*$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;*/
		}
		
		function GetList()
		{						
			$this->setQuery("set names utf8");
			$this->query();			
			/*$sql = "Select cp.*, c.*, p.* from vnf_category_product cp
            INNER JOIN vnf_category c ON cp.CategoryID = c.category_id
            INNER JOIN vnf_product p ON cp.ProductID = p.ProductNo ";*/
            $sql = "Select * from vnf_category_product";	
			$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;
		}
        
        function AddCategoryProduct($CategoryID, $ProductID)
		{
            $DateSubmit=date('Y-m-d H:i:s', time());
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Insert into vnf_category_product(`CategoryID`, `ProductID`) 
            values('".$CategoryID."', '".$ProductID."')";
            //echo $sql;
			$this->setQuery($sql);
			$this->query();
		}
		
		function UpdateCategoryProduct($CategoryID, $ProductID, $id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Update vnf_category_product set `CategoryID` =  '".$CategoryID."', 
            `ProductID` = '".$ProductID."'";
			$sql .= " where CPID=".$id;	
            //echo $sql;		
			$this->setQuery($sql);
			$this->query();
		}
		
		function GetOneCategoryProduct($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Select * from vnf_category_product where CPID=".$id."";
			$this->setQuery($sql);
			$row = $this->loadOneRow();
			return $row;
		}
		
		function DeleteCategoryProduct($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Delete from vnf_category_product ";
			$sql .= " where CPID=".$id;			
			$this->setQuery($sql);
			$this->query();
		}
	
		
	}
?>